﻿using UnityEngine;

namespace UnityBasicGem.Example1
{
	public class Ball : MonoBehaviour
	{
		void Start()
		{
			// 创建 Ball 之后，给一个左上方向的初速度
			GetComponent<Rigidbody>().velocity = new Vector3(-10.0f, 9.0f, 0.0f);
		}

		/// <summary>
		/// 当移出屏幕时销毁自己
		/// </summary>
		void OnBecameInvisible()
		{
			Destroy(gameObject);
		}
	}
}